import pytest
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
from time import sleep
class TestOA:
    @pytest.fixture()
    def get_driver(self):
        driver = webdriver.Chrome()
        driver.get("http://192.168.1.138/ranzhi/www/sys/index.html")
        yield driver
        driver.quit()

    testdata = [("admin","123456","签退"),
                ("","123456","登录失败，请检査您的成员名或密码是否填写正确。"),
                ("admin","","登录失败，请检査您的成员名或密码是否填写正确。")
                ]
    @pytest.mark.parametrize("username, password, expect", testdata)

    # @pytest.mark.run
    def test_login(self, get_driver, username, password, expect):
        driver = get_driver
        try:
            driver.maximize_window()
            sleep(2)
            driver.find_element(By.ID,  "account").send_keys(username)
            sleep(2)
            driver.find_element(By.ID,"password").send_keys(password)
            sleep(2)
            driver.find_element(By.ID, "submit").click()
            sleep(2)
            # if expect == "签退":
            #     text = driver.find_element(By.LINK_TEXT,"签退").text
            # elif expect == "登录失败，请检査您的成员名或密码是否填写正确。":
            #
            # else:
            #     pass


            # assert text == expect ,"登录失败"
        except AssertionError as e:
            print(f"Assertion failed: {e}")
            raise
        except Exception as e:
            print(f"An error occurred: {e}")
            raise







